<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="平台：">
        <el-radio-group v-model="form.platform">
          <el-radio label="1">电信</el-radio>
          <el-radio label="2">移动</el-radio>
          <el-radio label="3">联通</el-radio>
        </el-radio-group>

        <el-popconfirm
          title="确定要保存更新吗？"
          @onConfirm="onSubmit"
        >
          <el-button slot="reference" type="primary" style="margin-left: 50px">保存</el-button>
        </el-popconfirm>
      </el-form-item>
      <el-form-item label="首页背景：">
        <div class="image-preview">
          <div v-show="imgFile.homebg.url!=''" class="image-preview-wrapper">
            <img :src="imgFile.homebg.url">
            <div class="image-preview-action">
              <i class="el-icon-delete" @click="" />
            </div>
          </div>
        </div>
        <el-upload
          action="https://jsonplaceholder.typicode.com/posts/"
          list-type="picture-card"
          :on-preview="handlePictureCardPreview"
          :on-remove="handleRemove"
          :auto-upload="false">
          <i class="el-icon-plus"></i>
        </el-upload>

        <el-dialog :visible.sync="dialogVisible" >
          <img width="100%" :src="dialogImageUrl" alt="">
        </el-dialog>

      </el-form-item>

      <el-form-item label="游戏页背景：">
        <el-upload
          action=imgFile.gamebg.url
          list-type="picture-card"
          :limit="1"
          :auto-upload="false"
          v-model="imgFile.gamebg"
        >
          <i slot="default" class="el-icon-plus"></i>
          <div slot="file" slot-scope="{file}">
            <img
              class="el-upload-list__item-thumbnail"
              :src="file.url" alt=""
            >
            <span class="el-upload-list__item-actions">
<!--         预览图小功能：大图查看-->
        <span
          class="el-upload-list__item-preview"
          @click="handlePictureCardPreview(file)">
          <i class="el-icon-zoom-in"></i>
        </span>
              <!--         预览图小功能：下载-->

        <span
          v-if="!disabled"
          class="el-upload-list__item-delete"
          @click="handleDownload(file)"
        >
          <i class="el-icon-download"></i>
        </span>
              <!--         预览图小功能：删除-->
        <span
          v-if="!disabled"
          class="el-upload-list__item-delete"
          @click="handleRemove(file)"
        >
          <i class="el-icon-delete"></i>
        </span>
      </span>
          </div>
        </el-upload>
      </el-form-item>

    </el-form>

  </div>
</template>

<script>
  export default {
    data() {
      return {
        // 这是个网络
        // https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943
        imgFile:{
          homebg:{
            url:'https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943',
            name:''
          },
          gamebg:{
            url:'https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943',
            name:''
          },
          diaSucc:{
            url:'',
            name:''
          },
          diaFail:{
            url:'',
            name:''
          },
          diaTimeOut:{
            url:'',
            name:''
          },
          diaTel:{
            url:'',
            name:''
          },

        },

        dialogImageUrl: '',
        dialogVisible: false,
        disabled: false,
        form: {
          // code: '',
          // region: '',
          // date1: '',
          // date2: '',
          // open: true,
          // type: [],
          platform: '1',
          // desc: ''
        }
      }
    },
    computed: {
      imgUrl(){
        return this.imgFile.tempUrl;
      }
    },
    methods: {
      handleRemove(file) {
        // console.log(file.url)
        // console.log(JSON.stringify(file))
        // file = ''
        // this.$emit('input', '')
        // this.disabled = true
      },
      handlePictureCardPreview(file) {
        this.dialogImageUrl = file.url
        this.dialogVisible = true
      },
      handleDownload(file) {
        console.log('下载功能暂未开放')
      },

      onSubmit(){

        console.log("保存更新")
      }

    }
  }
</script>

<style scoped>
  .line {
    text-align: center
  }
</style>

